/**********************************************************/
/* Goblin Defense - A tower defense game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro              */
/* Licensed under de GNU General Public License v2.0      */
/*   See license_gplv2.txt for detalis                    */
/**********************************************************/

#ifndef __TOOL_WEAPON_H_
#define __TOOL_WEAPON_H_

#include <gccore.h>

#include "map.h"
#include "weapon.h"

class ToolWeapon {
private:
	u32 pos;

	f32 get_x() const;
	f32 get_y() const;

public:
	ToolWeapon(u32 pos) : pos(pos) {}
	~ToolWeapon() {}

	virtual UpgradableWeapon *buy_at(f32 x, f32 y) const = 0;
	virtual u32 gold_price() const = 0;
	virtual u32 shoe_price() const = 0;
	virtual u32 horn_price() const = 0;
	virtual u32 get_sprite() const = 0;
	virtual u32 get_position_type() const = 0;

	void draw_tool() const;
	void mark_selected(u8 cr, u8 cg, u8 cb, u8 ca) const;
	void draw_cursor(u8 cr, u8 cg, u8 cb, u8 ca) const;
	int inside(f32 cursor_x, f32 cursor_y) const;
};

template <class W>
class ToolItem : public ToolWeapon {
public:
	ToolItem(u32 pos) : ToolWeapon(pos) {}
	UpgradableWeapon *buy_at(f32 x, f32 y) const { return new W(x, y); }
	u32 gold_price() const { return W::gold_price; }
	u32 shoe_price() const { return W::shoe_price; }
	u32 horn_price() const { return W::horn_price; }
	u32 get_sprite() const { return W::sprite; }
	u32 get_position_type() const { return W::position_type; }
};

#endif
